using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;

namespace SolarWinds.Widgets
{
    public class StatisticsDisplay : Window
    {
        public Dictionary<String, float> Statistics = new Dictionary<string, float>();

        public StatisticsDisplay(Game game)
            : base(game)
        {
            BoundingRect = new Rectangle(10, 10, 200, 105);
            Caption = "Game Statistics";
        }

        protected internal override void PaintEvent()
        {
            base.PaintEvent();

            float height = Font.MeasureString(Caption).Y;

            var col1 = new Vector2(ScreenPosition.X + 20, ScreenPosition.Y + 15);
            var col2 = new Vector2(ScreenPosition.X + 140, ScreenPosition.Y + 15);

            foreach (KeyValuePair<string, float> statistic in Statistics)
            {
                SpriteBatch.DrawString(Font, statistic.Key + ": ", col1, Color.White);
                SpriteBatch.DrawString(Font, statistic.Value.ToString("N2"), col2, Color.White);
                col1.Y += height;
                col2.Y += height;    
            }
        }
    }
}